<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
  	<script type="text/javascript" src="js/jquery-1.8.2.js"></script> 
    <script type="text/javascript" src="js/common.js"></script> 
	<script type="text/javascript" src="js/jquery.form.js"></script>
</head>
  <body>
 
   <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">用户添加</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9">
    	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	      <tr>
	        <td colspan="2" valign="top">
	      		<!--  控件按钮栏-->
		         <TABLE class=main_tab id=mainTable cellSpacing=0 cellPadding=0 width=100% border=0>
		             <tr>
		             	<td>
		                 	 <input type="button" name="saveMerchant"  id="saveMerchant"  value="保存" onclick="submitForm()">
		                </td>
		             </tr>
			      </TABLE>
		     </td>
		     <td>&nbsp;</td>
		  </tr>
		  <tr>
	        <td height="40" colspan="4">
	        	<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
			          <tr>
			            <td></td>
			          </tr>
	        	</table>
	        </td>
		  </tr>
		  <tr>
		  	 <td colspan="30">
		     <!--  table栏-->
		      <form id="saveMerchantForm" action="<%=basePath%>/merchantAction_saveMerchant.action"  method="post">
				    <table align="left">  
				      <tr>
					       	<td> 商户编号:</td>
					       	<td> <input type="text"  id="stMerchantNumber"  name="merchantBean.stMerchantNumber"  /><font size="5" color="#FF4500">*</font></td>
					       	<td> 商户名称: </td>
					       	<td> <input type="text"  id="stMerchantName"  name="merchantBean.stMerchantName"  /><font size="5" color="#FF4500">*</font></td>
					  </tr>
					  <tr>
					   
					  		<c:set var="resultList" scope="request" value="${areaPart}"/>
					  		<td>商户所在地区：</td>
					  		<td>
					  			<select  id="stAreaPart"  name="areaBean.stAreaPart" style="width:150px">
					  			<option value="" selected></option>
						  			<c:choose> 
								  		<c:when test="${not empty resultList}">
									  		<c:forEach items="${resultList}"  var="op">  
											   <option value="${op}">${op}</option>
											</c:forEach> 
								  		</c:when>
								  	</c:choose>
							  	</select>
					  		</td>
					  		<td>商户所在省市：</td>
					  		<td>
					  			<select  id="stAreaType"  name="areaBean.stAreaType" style="width:150px">
					  			</select>
					  		</td>
					  		<td>商户所在城市名称：</td>
					  		<td>
					  			<select  id="stAreaName"  name="areaBean.stAreaName" style="width:150px">
					  			</select>
					  		</td>
					       	<td> <input type="hidden"  id="stArea"  name="merchantBean.stMerchantArea"  /></td>
					       
					  </tr>
					   <tr>
					   		<td>商户所在地址：</td>
					       	<td> <input type="text"  id="stMerchantAddress"  name="merchantBean.stMerchantAddress"  /></td>
					  		<td>商户所在区域邮编：</td>
					  		<td><input type="text"  id="stMerchantPostCode"  name="merchantBean.stMerchantPostCode"  /></td>
					       	
					  </tr>
					  <tr>
					  		<td>商户固定电话：</td>
					       	<td> <input type="text"  id="stMerchantPhone"  name="merchantBean.stMerchantPhone"  /></td>
					  		<td>商户移动电话：</td>
					       	<td> <input type="text"  id="stMerchantMobile"  name="merchantBean.stMerchantMobile"  /></td>
					       	<td>商户邮箱：</td>
					       	<td> <input type="text"  id="stMerchantEmail"  name="merchantBean.stMerchantEmail"  /></td>
					  </tr>
					  <tr>
					  		<td>商户联系人：</td>
					       	<td> <input type="text"  id="stMaintainPerson"  name="merchantBean.stMaintainPerson"  /></td>
					       	<td>商户等级：</td>
					       	<td> <select  id="stMerchantLevel"  name="merchantBean.stMerchantLevel" >
					       	 		 <option value="1900" selected>普通商户</option>
						       		 <option value="1901" >中等商户</option>
						       		 <option value="1902" >VIP商户</option>
					       		</select></td>
					  </tr>
					  <tr>
					       	<td>是否为子商户：</td>
					        <td> <select  id="stSub"  name="merchantBean.stSub" >
					       	 		 <option value="1920" selected>总公司</option>
						       		 <option value="1921" >分公司</option>
					       		</select></td>
					  		<td>合并商户ID：</td>
					       	<td> <input type="text"  id="stCombNumber"  name="merchantBean.stCombNumber"  /></td>
					  		<td>商户状态:</td>
					       	<td><select id="stState"  name="merchantBean.stState">
						       	     <option value="1000" selected>有效</option>
						       		 <option value="9999" >无效</option>
					       	    </select><font size="5" color="#FF4500">*</font>
					       	</td>
					  </tr>
					   <tr>
					       
					       	<td>用户备注：</td>
					       	<td><textArea  id="stRemark"  name="merchantBean.stRemark" cols="25" rows="4"></textArea> </td>
					  </tr>
				 	</table>
				</form>
		        </td>
		  </tr>
		  <!-- 翻页工具  -->
		  <tr>
		     <td colspan="8">
		     </td>
		  </tr>
	      <tr>
	        <td height="40" colspan="4">
	        	<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
			          <tr>
			            <td></td>
			          </tr>
	        	</table>
	        </td>
	      </tr>
	      <tr>
	        <td width="2%">&nbsp;</td>
	        <td width="51%" class="left_txt"><img src="images/icon-mail2.gif" width="16" height="11"> <br>
	              <img src="images/icon-phone.gif" width="17" height="14"></td>
	        <td>&nbsp;</td>
	        <td>&nbsp;</td>
	      </tr>
	</table>
    </td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
</tr>
<tr>
   <td valign="bottom" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
   <td background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17"></td>
   <td valign="bottom" background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
</tr>
</table>

  </body>
  <script type="text/javascript">
	function submitForm(){  
	    var stMerchantNumber =  document.getElementById("stMerchantNumber").value;  
	    var stMerchantName =  document.getElementById("stMerchantName").value;  
	    var stArea =  document.getElementById("stArea").value;  
	    var stMerchantAddress =  document.getElementById("stMerchantAddress").value;  
	    var stMerchantPostCode =  document.getElementById("stMerchantPostCode").value;  
	    var stMerchantPhone =  document.getElementById("stMerchantPhone").value; 
	    var stMerchantMobile =  document.getElementById("stMerchantMobile").value;
	    var stMerchantEmail =  document.getElementById("stMerchantEmail").value;
	    var stMaintainPerson =  document.getElementById("stMaintainPerson").value;
	    var stMerchantLevel =  document.getElementById("stMerchantLevel").value;
	    var stSub =  document.getElementById("stSub").value;
	    var stCombNumber =  document.getElementById("stCombNumber").value; 
	    var stState =  document.getElementById("stState").value;
	    var stRemark =  document.getElementById("stRemark").value;
		
		if(stMerchantNumber == null || stMerchantNumber == ""){
			alert("商户编号不能为空");
			return false;
		}
		
		if(stMerchantName == null || stMerchantName == ""){
			alert("商户名称不能为空");
			return false;
		}
		
		if(stArea == null || stArea == ""){
			alert("商户区域不能为空");
			return false;
		}
		      
		var  regNumber=/^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/;
		if(!regNumber.exec(stMerchantMobile)){
			alert("商户移动电话格式错误");
			return false;
		}
		
		regNumber=/^[0-9]{0,8}$/;
		if(!regNumber.exec(stMerchantPhone)){
			alert("商户固定电话格式错误");
			return false;
		}
		
		regNumber=/^[0-9a-zA-Z]{0,24}$/;
		if(!regNumber.exec(stMerchantNumber)){
			alert("商户编号长度或格式出错");
			return false;
		}
		
		var form = document.getElementById("saveMerchantForm");  
		form.submit();   
    }
</script>
</html>
